package lab03.test07;

import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Test {
    public static void main(String[] args) {
        String path = "D:\\book.zip";
//        File path1 = new File("D:\\");
        ZipInputStream zipInputStream = null;
        BufferedReader bufferedReader = null;
        BufferedWriter bufferedWriter = null;
        try {
            try {
                zipInputStream = new ZipInputStream(new FileInputStream(path));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }

            byte[] b = new byte[1024];
            //entry：压缩包中的信息
            ZipEntry entry;
            try {
                while ((entry = zipInputStream.getNextEntry()) != null) {
    //                System.out.println(entry.getName());

    //                File file=new File(path1,entry.getName());

                    File file = new File("F:\\" + entry.getName()); // 获取文件目录
                    System.out.println(file);
                    if (!file.exists()) { // 如果该文件不存在
                        file.mkdirs();// 创建文件所在文件夹
                        file.createNewFile(); // 创建文件
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        } finally {
            try {
                zipInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

}

